package Homework5;

import java.util.*;

public class Homework5_6_TestIntersectionAndUnion {
    public static void main(String[] args) {
        ArrayList<Integer> list1 = new ArrayList<>();
        ArrayList<Integer> list2 = new ArrayList<>();
        Scanner input = new Scanner(System.in);
        int n;
        n = input.nextInt();
        for(int i=1;i<=n;i++)
            list1.add(input.nextInt());
        n = input.nextInt();
        for(int i=1;i<=n;i++)
            list2.add(input.nextInt());
        ArrayList<Integer> list3
                = IntersectionAndUnion.intersection(list1,list2);
        ArrayList<Integer> list4
                = IntersectionAndUnion.union(list1,list2);
        System.out.println("intersection:");
        System.out.println(list3.toString());
        System.out.println("union:");
        System.out.println(list4.toString());
    }
}
